<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 12138
  Date: 2020/12/22
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <meta charset="utf-8">
  <title>仓颉博客</title>
  <link rel="stylesheet" type="text/css" href="css/style_index.css">
  <link rel="stylesheet" type="text/css" href="css/common_index.css">

</head>

<body>
<div id="head">
  <img src="img/biao.png"/>
  <form method="post" action="/QM_war_exploded/Select" id="formSelecte">
  <input type="text" name="keyWord" id="se" placeholder="输入关键词">
  <div id="essaySelect"><p  class="icon-sk008"></p> </div>
  </form>
  <ul>
    <li><p id="li_index" class="icon-sk035">&nbsp;首页</p></li>
    <li><p id="li_ji" class="icon-sk056">&nbsp;技术</p></li>
    <li><p id="li_news" class="icon-sk018">&nbsp;新闻</p></li>
    <li><p id="li_man" class="icon-sk011">&nbsp;人物</p></li>
    <li id="user"><p class="icon-sk046"><a id="den">登录管理账号</a></p></li>
  </ul>
</div>

<div id="body">
 <%-- <form hidden="true" method="post" action="/QM_war_exploded/MainFlash" style="z-index: 999">
    i<br>
    <input type="submit" id="main_flash" value="提交">
    i<br>
  </form>--%>


  </div>


</div>

<div id="top_label">
  <h4 id="top_label_title">热门标签</h4>

</div>
<div id="top_essay">
  <h4 id="top_essay_title">热门文章</h4>

</div>
<div id="bottom">
  <p>Copyright©2020 仓颉博客版权所有</p>
</div>

</body>

<script type="text/javascript" src="js/jquery-3.5.1.js"></script>
<script type="text/javascript" >
  $(function(){
    init()
    function init() {
      /*if(sessionStorage.getItem("isReload")){
        alert("页面被刷新");

      }else{
        alert("首次被加载");
       // $("#main_flash").click();
        sessionStorage.setItem("isReload", true)
      }*/
      <% List<String[]> essayList=(List<String[]>)session.getAttribute("essayList");
           List<String[]> essayLabelList=(List<String[]>)session.getAttribute("essayLabelList");
           String[] topLabel=(String[])session.getAttribute("topLabel");
            String[] topEssay=(String[])session.getAttribute("topEssay");
        %>
      alert('<%=session.getAttribute("msg")%>')
      <%for ( String[] s: essayList) {%>
      var str='  <div class="item' ;
      <%
        switch (s[3]){
          case "技术":%>str+=' ji'<%
        break;
          case "新闻":%>str+=' news'<%
        break;
          case "人物":%>str+=' man'<%
        break;
        default:
       }%>
        str+='   "> <h3><%=s[2]%></h3><br>\n' +
              '    <p></p>\n' +
              '    <div class="div_label">\n' ;
        <%for (String[] x:essayLabelList){
            if(s[0].equals(x[0])){%>
              str+='<div class="lable_item">&nbsp;#<%=x[2]%>#&nbsp;</div>'
            <%}
      }%>
          str+= '<p class="read_sum">阅读量：<%=s[7]%></p><p class="zan_sum">赞：<%=s[8]%></p><p class="auther">作者:<%=s[9]%></p>\n' +
              '    </div>\n' +
               '<form hidden="true" class="show" method="post" action="/QM_war_exploded/ShowEssay" style="z-index: 999">\n' +
                  '   <input type=\'hidden\' value=\'<%=s[0]%>\' name=\'fromeid\'>' +
                  '    <input type="submit"  value="提交">\n' +
                  '   \n' +
                  '</form>'+
              '  </div>'
      $("#body").append(str)
      <%} %>
      var str1=''
      <%for (String s :topEssay ) {%>
         str1+='<div class="essay_item"><%=s%></div>'
      <%}%>
      $("#top_essay").append(str1)
      var str2=''
      <%for (String s :topLabel ) {%>
      str2+='<div class="lable_item">&nbsp;#<%=s%>#&nbsp;</div>'
      <%}%>
      $("#top_label").append(str2)
    }
    $("#essaySelect").on("click",function () {
      alert($("#se").val())
      $("#formSelecte").submit();
      //window.location.href = "select.jsp";
    })
    $(".item").on("click",function () {
      $(this).children(".show").submit()
      /*alert($(this).children(".show").attr("method"))*/
    })
    $("#den").on("click",function () {
      window.location.href="login.jsp";
    })
    $("#li_index").on("click",function(){
      $(".item").show();
    });
    $("#li_ji").on("click",function(){
      $(".item").hide();
      $(".ji").show();
    });
    $("#li_news").on("click",function(){
      $(".item").hide();
      $(".news").show();

    });
    $("#li_man").on("click",function(){
      $(".item").hide();
      $(".man").show();

    });
  });
</script>
</html>

